/**
 * 
 * @author Travis C Lynch
 * @version Jan 17 2012
 * 
 * <b>Description</b>
 * A base class that calculates and creates a string that shows the return on an investment with the rate and period giving
 *
 */

public class Investment {

	private int Pireod; /** How may years of the investment */
	private double Rate; /** Rate of investment */
	private int[] Return; /** return on investment */
	
	/**
	 * @param i Inital Investment Ammount
	 * @param p Period of the investment
	 * @param r Intrest rate
	 */
	public Investment(int i, int p, double r){
		Return = new int[p+1];
		Pireod = p;
		Rate = r;
		Return[0]=i;
		for(int j = 1; j<=p;j++){
			Return[j]= (int)Math.round(((Return[j-1] * Rate) + Return[j-1]));
		}
	}
	public String toString(){
		String toString = "";	/** String Vslue to return */
		int space=0;		/** # of spaces */
		int i=0,j;		/** counters */
		while(i<=Pireod){
			space=(8-(""+Return[i]).length());
			j=0;
			while(j<space){
				toString = toString + " ";
				j++;
			}
			toString = toString + Return[i];
			i++;
		}
		return toString;
	}
}
